// -*- coding: utf-8 -*- 
/**
 * Project: AlgorithmsLearn
 *
 * @author: yanking
 * Create time: 2022-04-18 11:40
 * IDE: IntelliJ IDEA
 * Introduction:
 */
package com.ACWing.DataTrains.CodeLock;

import java.util.Arrays;
import java.util.Scanner;

public class CodeLock {
    // 密码锁
    public static void main(String[] args) {
        Scanner myScanner = new Scanner(System.in);
        /*-----获取数据-----*/
        int n = myScanner.nextInt();
        int[] John = new int[3], fac = new int[3];
        for (int i = 0; i < 3; ++i) {
            John[i] = myScanner.nextInt();
        }
        for (int i = 0; i < 3; ++i) {
            fac[i] = myScanner.nextInt();
        }
        /*-----简单枚举-----*/
        int ans = 0;
        int[] count = new int[3];
        Arrays.fill(count, 1);
        for (int i = 0; i < 3; ++i) {
            int p = 2;
            while (p > 0) {
                if (John[i] + p <= n) {
                    count[i]++;
                }
                if (John[i] - p >= 1) {
                    count[i]++;
                }
                p--;
            }
        }
        ans += count[0] * count[1] * count[2];
        Arrays.fill(count, 1);
        for (int i = 0; i < 3; ++i) {
            int p = 2;
            while (p > 0) {
                if (fac[i] + p <= n) {
                    count[i]++;
                }
                if (fac[i] - p >= 1) {
                    count[i]++;
                }
                p--;
            }
        }
        ans += count[0] * count[1] * count[2];
        System.out.println(ans);
    }
}
